package prototype;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author : DuJiabao
 * @Date : 2021/3/1 22:12
 * @Project : design-pattern
 * @File : null.java
 * @Desc :
 */
public class CloneTest {
  public static void main(String[] args) throws CloneNotSupportedException {
    Sheep sheep = new Sheep("多莉");
    Sheep clone = (Sheep)sheep.clone();
    System.out.println(sheep == clone);
    System.out.println(sheep.getName() == clone.getName());
    System.out.println(sheep);
    System.out.println(clone);
  }

  @Test
  public void test() throws CloneNotSupportedException {
    DeepClone1 deepClone1 = new DeepClone1(new ArrayList());
    DeepClone1 clone = (DeepClone1)deepClone1.clone();
    System.out.println(clone.arrayList == deepClone1.arrayList);
  }

  @Test
  public void test2() throws CloneNotSupportedException {
    DeepClone2 deepClone2 = new DeepClone2(new ArrayList());
    DeepClone2 clone = deepClone2.deepClone();
    System.out.println(clone.arrayList == deepClone2.arrayList);
  }
}
